package com.gitee.qdbp.general.system.api.permission.model;

import com.gitee.qdbp.able.model.reusable.ExtraData;

/**
 * 资源选项
 *
 * @author zhh
 * @version 180514
 */
public class ResourceOptions extends ExtraData {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    private String icon;

    private String color;

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    /**
     * 将ResourceOptions转换为子类对象
     *
     * @param bean 待转换的对象
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends ResourceOptions> T to(Class<T> clazz) {
        T instance;
        try {
            instance = clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(clazz.getSimpleName() + " new instance error.", e);
        }

        instance.setIcon(icon);
        instance.setColor(color);
        return instance;
    }

}